*********************************************
/* 		Title: Merge and analysis of Stanford and CAFC datasets */
/* 		Project: Who Appeals Patent Cases */
/*		Date: 2022-10-21 */
*********************************************

// This file contains the replication code for 'Who Appeals Patent Cases?' To execute this file, you will need the following files: 

/* 
- Stanford Dataset 2022-05-02PDT08-37-42.xlsx // This is the Stanford NPE Litiation Dataset as of May 2, 2022
- 2020-02-20 Key for District Codes.dta // key file for formatting district field
- CAFC Docket Dataset with formatted cv numbers 2011-2021.dta // This is the dataset of appeal dockets generated from the Federal Circuit Dataset project with district court docket number formatting standardized.
- appeals 2022-04-06.dta // this is the current version of the document dataset from the Federal Circuit Dataset Project
- 2022-06-30 keyword preliminary injunction.dta - file containing the uniqueID numbers for decisions that contain this term.
*/

// NOTE: The user will either need to place the above files in the following directory or update the below path to the correct file location

cd "~/Who Appeals Patent Cases/Data and Code"



**************************
/* Part II.A - Preparation of the Stanford dataset */
**************************

// Begin with the Stanford dataset. This analysis used the dataset as of 2022-05-02. 

import excel "Stanford Dataset 2022-05-02PDT08-37-42.xlsx", sheet("cases-2022-05-02PDT08-37-42") firstrow clear

merge m:1 Venue using "2020-02-20 Key for District Codes.dta" // Converts the district information to the same format as used in the Federal Circuit dataset.

// There are a miniscule number of records with district_id codes that do not have a corresponding match in the Stanford dataset. These are negligible and will be dropped. 

drop if _merge==2

drop _merge

gen CivilAction_Stanford=CivilAction // The CivilAction field is shared with the Federal Circuit dataset we will be merging with. Note that Civil Action numbers are only unique within a district. Different districts can have the same Civil Action number. 

duplicates report CivilAction district_id 
// This indicates that there are 76,372 unique civil actions in the set, of which 14 have duplicates. The 14 duplicates are dropped. 

duplicates drop CivilAction district_id, force

rename FilingDate FilingDate_DCT
gen Case_Filed_Year = year(FilingDate_DCT)

save "Stanford Dataset with district_id.dta", replace // Saving the intermediate dataset.

**************************
/* Part II.B - Creation of the "first appeal" dataset */
**************************

// STEP 1: Creation of the first appeal filed docket dataset

use "CAFC Docket Dataset with formatted cv numbers 2011-2021.dta", clear

keep if origin=="DCT" & Misc_Docket!=1 & Year_Appeal_Filed > 2010 // The appeal docket set used in this paper consists of (1) appeals arising from the district courts that were (2) filed at the Federal Circuit after 2010 (3) excluding miscellaneous matters (i.e.: petitions for writs of mandamus or permission to appeal). Except in rare instances, each appeal docket is associated with only a single civil action number. In these rare instances, the first civil action number is used. 

duplicates report PACER_ID // This provides the number of unique appeal dockets in the dataset. All appeal docket numbers are unique. Note that Appeal_Docket and PACER_ID contain the same information that is formatted in a different way. 

sort PACER_ID DateFiledinCOA // This will ensure that the earliest appeal filed at the CAFC is kept

duplicates drop district_id CivilAction, force // This drops subsequent appeals arising from the same civil action.

save "CAFC docket dataset - temp.dta", replace

use "Stanford Dataset with district_id.dta", clear

duplicates report district_id CivilAction // Verification that the dataset is unique with respect to district_id and Civil Action.

merge 1:1 district_id CivilAction using "CAFC docket dataset - temp.dta" // This merge matches on the district that the case originated from and the complete civil action number (including the division)

drop _merge

//The result is a successful merge: ~2940 out of ~3453 appeal dockets matched for the selected time frame.  

gen dataset_Stanford=1 if case_node_id!=.
replace dataset_Stanford=0 if dataset_Stanford==.
gen dataset_CAFC_docket=1 if PACER_ID!=""
replace dataset_CAFC_docket=0 if dataset_CAFC_docket==.
// These commands generate a dummy variable that indicates which dataset the record is found in.

tab Year_Appeal_Filed dataset_Stanford
// This table shows us that for 2011-2021, about 85% of the docket numbers in the CAFC appeal set match to at least one docket number in the Stanford set, and about 15% do not match.  This is a what we would expect based on past observations that about 15% of Federal Circuit decisions do not involve patent infringement. 

tab Case_Filed_Year Year_Appeal_Filed
gen time_to_appeal= DateFiledinCOA-FilingDate_DCT
histogram time_to_appeal, bin(25) percent
// This historgram provides a quick view of the distribution of time to appeal.

summarize time_to_appeal
summarize time_to_appeal if Case_Filed_Year >2010 & Case_Filed_Year<2017
// Summary data on time to appeal 


tab Case_Filed_Year dataset_CAFC_docket
gen Years_to_Appeal = int(time_to_appeal / 365.25)
label define Years_to_Appeal 0 "0-1" 1 "1-2" 2 "2-3" 3 "3-4" 4 "4-5" 5 "5-6" 6 "6-7" 7 "7-8" 8 "8-9" 9 "9-10" 10 "10-11" 11 "11-12" 12 "12-13" 13 "13-14+" 16 "16-17" 17 "17-18"
label val Years_to_Appeal Years_to_Appeal

tab Years_to_Appeal

tab Case_Filed_Year Years_to_Appeal // This table provides the data used in Table 1 of the paper.

save "District court cases and first appeals", replace

erase "CAFC docket dataset - temp.dta"

////////////////////////////

// Step 2: Merge the first appeal dataset into the appeal document dataset

use "appeals 2022-04-06.dta", clear

keep if docType=="Rule 36" | docType=="Opinion" // Note that this necessarily drops decisions in Misc Dockets because these are decided by orders not by opinions or summary affirmances. 
keep if origin=="DCT"
keep if Replaced==""
keep if year>2010 // Docket dataset begins in 2011, so we only need decisions after that. 

drop if uniqueID==30275 | uniqueID==28919 | uniqueID==27341

duplicates report Appeal_Dockets //data is unique with respect to the Appeal Dockets field at this point - but remember that because a single decision can have multiple appeal dockets, the Appeal_Dockets field needs to be reshaped long. 

keep uniqueID docDate origin Appeal_Dockets year DisputeType DispGeneral Appellant_Type_Primary Appellant_Type_Cross docType PrecedentialStatus CloudLink // Limiting the dataset to key fields improves computation speed. 

split Appeal_Dockets, parse(;) gen(Appeal_Dockets_)
reshape long Appeal_Dockets_, i(uniqueID) j(new_var)

drop if Appeal_Dockets_ == ""
drop new_var

// Data is now long with respect to Appeal_Dockets.  

rename Appeal_Dockets_ Appeal_Docket // Each record is now a single appeal docket
replace Appeal_Docket = strtrim(Appeal_Docket)

duplicates report Appeal_Docket // There are two duplicate appeal dockets in this set.
duplicates drop Appeal_Docket, force

//data is now unique with respect to Appeal Dockets.  Each Appeal Docket is one record. Note that multiple appeal dockets can be associated with a single uniqueID (document)

save "CAFC decisions temp for merge.dta", replace

use "District court cases and first appeals", clear // This is the dataset of appeal dockets that was merged with the Stanford dataset above. 

keep if dataset_CAFC==1 // At this stage we are only working with Stanford dataset records that matched to an appeal docket. 

duplicates report Appeal_Docket // verification that data is unique with respect to Appeal_Docket

merge 1:1 Appeal_Docket using "CAFC decisions temp for merge.dta" // This merges the Appeal Docket dataset with the decisions dataset using the Appeal Docket number. The resulting matches provide the figure cited in II.C. (rate of appeal dockets to appellate decisions for first-appeal dataset)

// Explanation of why some Appeal Dockets to not match to a decision and vice versa:
// 		- master are records that are in the CAFC appeal docket dataset but that are not in the appeal decisions dataset
// 		- using are records that are in the appeal decisions dataset but not in the docket dataset
//		- matches are records found in both datasets

//  Records from dockets dataset that do not match to a record in the decisions dataset: Not all appeals result in a decision on the merits. Past estimates suggest that only about 60% of appeals result in a decision. In addition, many appeals filed in 2020 and 2021 had not yet resulted in a decision as of the date the decisions dataset. 

// Records from the decisions dataset that do not match to a record in the docket dataset: The primary reason for these non-matching records is that we removed all the subsequent Appeal Dockets for each civil action because this is a set of first appeals only. In addition, there are decisions on Appeal Dockets that were filed before 2011. 

// looking just at the matches by Appeal Docket. Again, this is the earliest appeal filed. In other words, who appealed first. In addition, because these are just appeals with a single appeal docketed, there are necessarily no cross appellants. 

keep if _merge==3 // This keeps only appeal dockets that are present in both the dockets and decisions dataset. 

duplicates report CivilAction district_id
// The dataset is now unique with respect to Civil Actions. 

duplicates report uniqueID 
// However, it is not unique with respect to opinions. In other words, multiple appeal dockets may be decided by a single opinion (and are)

tab dataset_Stanford
// This table indicates the portion of appeal dockets that matched to a decision that have a corresponding civil action in the Stanford dataset.

tab Appellant_Type_Primary if DisputeType=="Patent infringement" & dataset_Stanford==1
// General contextual information on the composition of the data.

keep if dataset_Stanford==1 // Only going to keep records that have a corresponding civil action in the Stanford dataset for the rest of the analysis. 

keep CivilAction district_id PACER_ID Year_Appeal_Filed DateFiledinCOA Appeal_Docket case_node_id FilingDate_DCT DJ AsserterCategory uniqueID docDate year origin Appeal_Dockets DisputeType DispGeneral Appellant_Type_Primary Appellant_Type_Cross docType Case_Filed_Year PrecedentialStatus // These are the key fields. 

// Next, data is reshaped wide so that the record unit is a Federal Circuit decision. 
sort uniqueID docDate
quietly by uniqueID: gen dup = cond(_N==1,0,_n)
replace dup = dup-1 if dup!=0

duplicates tag uniqueID, gen(dockets_n)
replace dockets_n = dockets_n + 1

reshape wide CivilAction district_id PACER_ID Year_Appeal_Filed DateFiledinCOA Appeal_Docket case_node_id FilingDate_DCT DJ AsserterCategory Case_Filed_Year, i(uniqueID) j(dup)

duplicates report uniqueID
// Documents are now unique with respect to Federal Circuit decisions.

tab dockets_n
// This shows the number of unique appeal dockets associated with each Federal Circuit decision. (Remember that appeals are unique with respect to Civil Actions.)
// In general, the number of unique Civil Actions per decision is relatively low as compared to the number of appeal dockets per appellate decision (calculated below). In other words, even though a single appellate decision might decide lots of docketed appeals, it's not necessarily deciding lots of civil actions.  Only about 11% of these patent infringement appellate decisions are actually deciding multiple civil actions.  

// Assessing whether there are differences in the Stanford asserter category between the first and second civil actions decided by appeals involving multiple civil actions. 
gen MultipleCivilActions = 1 if CivilAction1!=""
gen Agreement = 1 if AsserterCategory0 == AsserterCategory1 & MultipleCivilActions == 1
replace Agreement = 0 if Agreement!= 1 & MultipleCivilActions==1
tab Agreement
// Comparing the Asserter Category coding for the first two civil actions in multi-civil action decisions, almost all (94%) have identical asserter category coding.  

// Note that the dataset at this stage (first appeals after 2010 with decisions) is not saved because it is not employed in subsequent analyses. 


////////////////////////////////


// Step 3: Repeating the appeal docket to appellate decision merge for only civil actions filed between 2011 and 2016.

use "District court cases and first appeals", clear

duplicates report Appeal_Docket

keep if dataset_CAFC==1

keep if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 // This is just going to be for cases filed 2011-2016.

merge 1:1 Appeal_Docket using "CAFC decisions temp for merge.dta" 

duplicates report CivilAction district_id

keep if _merge==3
drop _merge

save "Civil Actions to Appellate decisions - first appeals (by docket) (2011-2016 cases).dta", replace // This saves a copy of the data with the appeal docket as the record unit.

duplicates report uniqueID 

tab dataset_Stanford if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 

duplicates report uniqueID if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & dataset_Stanford==1

tab dataset_Stanford

tab Appellant_Type_Primary if DisputeType=="Patent infringement" & dataset_Stanford==1

keep if dataset_Stanford==1  

keep CivilAction district_id PACER_ID Year_Appeal_Filed DateFiledinCOA Appeal_Docket case_node_id FilingDate_DCT DJ AsserterCategory uniqueID docDate year origin Appeal_Dockets DisputeType DispGeneral Appellant_Type_Primary Appellant_Type_Cross docType Case_Filed_Year PrecedentialStatus

sort uniqueID docDate
quietly by uniqueID: gen dup = cond(_N==1,0,_n)
replace dup = dup-1 if dup!=0

duplicates tag uniqueID, gen(dockets_n)
replace dockets_n = dockets_n + 1

reshape wide CivilAction district_id PACER_ID Year_Appeal_Filed DateFiledinCOA Appeal_Docket case_node_id FilingDate_DCT DJ AsserterCategory Case_Filed_Year, i(Appeal_Dockets) j(dup)

tab dockets_n

save "Civil Actions to Appellate decisions - first appeals (by document) (2011-2016 cases).dta", replace // This saves a copy of the dataset of cases filed in 2011-2016 with the appellate decision as the record unit. 


*************************
/* Creation of the "all appeals" dataset */
*************************

// STEP 1: Creation of the first appeal filed docket dataset

use "CAFC Docket Dataset with formatted cv numbers 2011-2021.dta", clear

keep if origin=="DCT" & Misc_Docket!=1 & Year_Appeal_Filed > 2010

keep PACER_ID Docket_Title DateFiledinCOA Appeal_Docket district_id CivilAction // We are going to keep the data simple for this merge

save "CAFC docket dataset - temp.dta", replace


////////////////////////////

// Step 2: Merge the first appeal dataset into the appeal document dataset

use "Stanford Dataset with district_id.dta", clear

duplicates report district_id CivilAction // Validating that records are unique with respect to these fields

merge 1:m district_id CivilAction using "CAFC docket dataset - temp.dta" // This is a one-to-many merge because a single civil action at the district court can have multiple appeals. 

// Note that because this is a 1 to many merge, the total number of records has increased.  Data is now unique with respect to Civil Action + district id + PACER_ID.  Because of this, do not directly make comparisons to the entire population of filed cases and appeals. Remember that each appeal docket (PACER_ID) continues to be associated with only one Civil Action + district ID

keep if _merge==3 // These are records that are in both the Stanford dataset and the appeal docket dataset

drop _merge

save "all district court dockets merge - temp.dta", replace

////////////////////////////

// Step 3: Analysis of civil actions with multiple appeals

sort district_id CivilAction
quietly by district_id CivilAction: gen dup = cond(_N==1,0,_n)
replace dup = dup-1 if dup!=0

gen Count = 1

keep CivilAction district_id DateFiledinCOA Appeal_Docket dup Count

reshape wide Appeal_Docket DateFiledinCOA Count, i(CivilAction district_id) j(dup) // This makes the record unit a civil actions.

tab Count0 if Count1!=1 // This indicates how many civil actions are associated with only a single appeal
tab Count1 // This indicates how many civil actions are associated with 2 or more appeals. 

reshape long DateFiledinCOA Appeal_Docket Count, i(CivilAction district_id) j(num)
drop if Count!=1
drop num

sort district_id CivilAction DateFiledinCOA
quietly by district_id CivilAction DateFiledinCOA: gen dup = cond(_N==1,0,_n)
replace dup = dup-1 if dup!=0

reshape wide Appeal_Docket Count, i(CivilAction district_id DateFiledinCOA) j(dup) // This makes the record unit a civil action with appeals filed on the same day.

tab Count1 // This indicates how many civil actions are associated with 2 or more appeals filed on the same day. 

use "all district court dockets merge - temp.dta", clear

duplicates drop CivilAction district_id DateFiledinCOA, force // Dropping cases with multiple appeals filed on the same day.

duplicates report CivilAction district_id

keep if Case_Filed_Year >2010 & Case_Filed_Year < 2017 // This gives us 2281 unique appeals across 1708 civil actions filed in 2011-2016 (excluding appeals in the same civil action that were filed on the same day)

duplicates report Appeal_Docket // This indicates the number of unique Appeal Dockets in the dataset
sort district_id CivilAction
quietly by district_id CivilAction: gen dup = cond(_N==1,0,_n)
replace dup = dup-1 if dup!=0

tab dup // This indicates the number of unique civil actions in this dataset

drop dup

save "civil action to appeal dockets - all appeals (2011-2016).dta", replace // Note data is unique with respect to appeal dockets and is limited to cases filed between 2010 and 2017.

erase "all district court dockets merge - temp.dta"


////////////////////////////

// Step 4: Merge with decisions dataset

use "appeals 2022-04-06.dta", clear

keep if docType=="Rule 36" | docType=="Opinion"
keep if origin=="DCT"
keep if Replaced==""
keep if year>2010 // Docket dataset begins in 2011 and thus there would not be any decisions before 2011.

drop if uniqueID==30275 | uniqueID==28919 | uniqueID==27341

duplicates report Appeal_Dockets

keep uniqueID docDate origin Appeal_Dockets year DisputeType DispGeneral Appellant_Type_Primary Appellant_Type_Cross docType PrecedentialStatus CloudLink

split Appeal_Dockets, parse(;) gen(Appeal_Dockets_)
reshape long Appeal_Dockets_, i(uniqueID) j(new_var)

drop if Appeal_Dockets_ == ""
drop new_var

// Data is now long with respect to Appeal_Dockets.  

rename Appeal_Dockets_ Appeal_Docket
replace Appeal_Docket = strtrim(Appeal_Docket)

duplicates report Appeal_Docket // There are two duplicate appeal dockets in this set.
duplicates drop Appeal_Docket, force

//data is now unique with respect to Appeal Dockets. 

save "CAFC decisions temp for merge.dta", replace

use "civil action to appeal dockets - all appeals (2011-2016).dta", clear

gen dataset_Stanford=1 if case_node_id!=.
replace dataset_Stanford=0 if dataset_Stanford==.

merge 1:1 Appeal_Docket using "CAFC decisions temp for merge.dta"

// _Merge 1 records are docketed appeals in infringement actions that didn't (or haven't yet) result in a decision. This is 66% - about what we would expect. _merge 2 records are decisions from the decisions dataset that don't match to an appeal docket.  This is expected, as some appellate decisions will be for cases before or after the 2011-2016 time period, and some appellate decisions will be for civil actions that are not in the Stanford dataset. In addition, we dropped the subsequent appeals in a single civil action that were filed on the same day.  

tab dataset_Stanford, missing

keep if _merge==3

drop _merge

// How many appellate decisions decide multiple appeals but a single civil action number? 

duplicates report uniqueID
// Lots of appellate decisions decide multiple appeals. (Remember that the record unit is an appeal docket)

duplicates report uniqueID CivilAction district_id
// However, many fewer decisions involve multiple civil actions. (Remember that while the record unit is an appeal docket, a single civil action can have multiple appeal dockets.)
// In other words, a substantial portion of the decisions (uniqueID) involve multiple appeals (Appeal_Docket) that arise from the same civil actions (district_id + CivilAction)

save "Civil Actions to Appellate decisions - all appeals (2011-2016).dta", replace
// Note that the record unit for this file is an appeal docket, not an appellate decision.

tab DisputeType
tab Appellant_Type_Primary if DisputeType=="Patent infringement"
// For contextual information

erase "CAFC decisions temp for merge.dta"


**************************************
/*	Part III: Analysis of Data */
**************************************

////////////////////////////

// Part III.A: Frequency of appeals by patent asserter case type

use "District court cases and first appeals", clear // This is the "first appeals" dataset of civil actions, prior to merge with the decisions dataset.

keep if dataset_Stanford==1 // We will only be using appeal dockets that matched to a record in the Stanford dataset. 
 
duplicates tag AsserterCategory, gen(AsserterCategory_n)
tab AsserterCategory if AsserterCategory_n > 100

/* There are a few multi-asserter categories that are very common in the Stanford dataset: 
1; 4 (Acquired patents + Corporate heritage)
1; 8 (Acquired patents + Product Company)
5; 8 (Individual inventor-started company + Product Company)
5; 9 (Individual inventor-started company + Individual)
6; 8 (University/Government/NGO + Product Company)
8; 12 (Product Company + IP Subsidiary of Product Company)
8 9 (Product Company + Individual)

*/

// First create binaries for the asserter categories

split AsserterCategory, parse(;) gen(AsserterCategory_)

destring AsserterCategory_1, replace
destring AsserterCategory_2, replace
destring AsserterCategory_3, replace
destring AsserterCategory_4, replace
destring AsserterCategory_5, replace


gen Cat_1 = 1 if AsserterCategory_1==1 | AsserterCategory_2==1 | AsserterCategory_3==1 | AsserterCategory_4==1 | AsserterCategory_5==1
replace Cat_1 = 0 if Cat_1==. & dataset_Stanford==1
label var Cat_1 "Acquired patents"

gen Cat_2 = 1 if AsserterCategory_1==2 | AsserterCategory_2==2 | AsserterCategory_3==2 | AsserterCategory_4==2 | AsserterCategory_5==2
replace Cat_2 = 0 if Cat_2==. & dataset_Stanford==1
label var Cat_2 "University heritage or ties"

gen Cat_3 = 1 if AsserterCategory_1==3 | AsserterCategory_2==3 | AsserterCategory_3==3 | AsserterCategory_4==3  | AsserterCategory_5==3
replace Cat_3 = 0 if Cat_3==. & dataset_Stanford==1
label var Cat_3 "Failed startup"

gen Cat_4 = 1 if AsserterCategory_1==4 | AsserterCategory_2==4 | AsserterCategory_3==4 | AsserterCategory_4==4  | AsserterCategory_5==4
replace Cat_4 = 0 if Cat_4==. & dataset_Stanford==1
label var Cat_4 "Corporate heritage"

gen Cat_5 = 1 if AsserterCategory_1==5 | AsserterCategory_2==5 | AsserterCategory_3==5 | AsserterCategory_4==5  | AsserterCategory_5==5
replace Cat_5 = 0 if Cat_5==. & dataset_Stanford==1
label var Cat_5 "Individual inventor-started company"

gen Cat_6 = 1 if AsserterCategory_1==6 | AsserterCategory_2==6 | AsserterCategory_3==6 | AsserterCategory_4==6  | AsserterCategory_5==6
replace Cat_6 = 0 if Cat_6==. & dataset_Stanford==1
label var Cat_6 "University/Government/NGO"

gen Cat_7 = 1 if AsserterCategory_1==7 | AsserterCategory_2==7 | AsserterCategory_3==7 | AsserterCategory_4==7  | AsserterCategory_5==7
replace Cat_7 = 0 if Cat_7==. & dataset_Stanford==1
label var Cat_7 "Startup, pre-product"

gen Cat_8 = 1 if AsserterCategory_1==8 | AsserterCategory_2==8 | AsserterCategory_3==8 | AsserterCategory_4==8  | AsserterCategory_5==8
replace Cat_8 = 0 if Cat_8==. & dataset_Stanford==1
label var Cat_8 "Product Company"

gen Cat_9 = 1 if AsserterCategory_1==9 | AsserterCategory_2==9 | AsserterCategory_3==9 | AsserterCategory_4==9  | AsserterCategory_5==9
replace Cat_9 = 0 if Cat_9==. & dataset_Stanford==1
label var Cat_9 "Individual"

gen Cat_10 = 1 if AsserterCategory_1==10 | AsserterCategory_2==10 | AsserterCategory_3==10 | AsserterCategory_4==10  | AsserterCategory_5==10
replace Cat_10 = 0 if Cat_10==. & dataset_Stanford==1
label var Cat_10 "Undetermined"

gen Cat_11 = 1 if AsserterCategory_1==11 | AsserterCategory_2==11 | AsserterCategory_3==11 | AsserterCategory_4==11  | AsserterCategory_5==11
replace Cat_11 = 0 if Cat_11==. & dataset_Stanford==1
label var Cat_11 "Industry Consortium"

gen Cat_12 = 1 if AsserterCategory_1==12 | AsserterCategory_2==12 | AsserterCategory_3==12 | AsserterCategory_4==12  | AsserterCategory_5==12
replace Cat_12 = 0 if Cat_12==. & dataset_Stanford==1
label var Cat_12 "IP Subsidiary of Product Company"

gen Cat_13 = 1 if AsserterCategory_1==13 | AsserterCategory_2==13 | AsserterCategory_3==13 | AsserterCategory_4==13  | AsserterCategory_5==13
replace Cat_13 = 0 if Cat_13==. & dataset_Stanford==1
label var Cat_13 "Corporate-Inventor-Started Company"


tab Cat_1 DJ
tab Cat_2 DJ
tab Cat_3 DJ
tab Cat_4 DJ
tab Cat_5 DJ
tab Cat_6 DJ
tab Cat_7 DJ
tab Cat_8 DJ
tab Cat_9 DJ
tab Cat_10 DJ
tab Cat_11 DJ
tab Cat_12 DJ
tab Cat_13 DJ
 
// The categories for all civil actions filed < 2017.
tab1 Cat_1 Cat_2 Cat_3 Cat_4 Cat_5 Cat_6 Cat_7 Cat_8 Cat_9 Cat_10 Cat_11 Cat_12 Cat_13 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 

//Replicating the results in Miller p. 294
tab1 Cat_1 Cat_2 Cat_3 Cat_4 Cat_5 Cat_6 Cat_7 Cat_8 Cat_9 Cat_10 Cat_11 Cat_12 Cat_13 if Case_Filed_Year < 2016 & includedinrandomsample==1  


////////////////

gen Multi_categories = 1 if (Cat_1 + Cat_2 + Cat_3 + Cat_4 + Cat_5 + Cat_6 + Cat_7 + Cat_8 + Cat_9 + Cat_10 + Cat_11 + Cat_12 + Cat_13) > 1
replace Multi_categories = 0 if Multi_categories !=1
tab Multi_categories if Case_Filed_Year > 2010 & Case_Filed_Year < 2017
// This shows how many civil actions had multiple categories.

// The categories for civil actions filed 2011-2016 that have an appeal at the CAFC
tab1 Cat_1 Cat_2 Cat_3 Cat_4 Cat_5 Cat_6 Cat_7 Cat_8 Cat_9 Cat_10 Cat_11 Cat_12 Cat_13 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & dataset_CAFC==1


////////////////////

// Part III.B. Frequency of appeals with decisions decisions by case type

use "Civil Actions to Appellate decisions - first appeals (by docket) (2011-2016 cases).dta", clear // The appeal docket is the record unit

tab docType if Case_Filed_Year==2012 
// Contextual information on the data 
 
duplicates tag AsserterCategory, gen(AsserterCategory_n)
tab AsserterCategory if AsserterCategory_n > 20

split AsserterCategory, parse(;) gen(AsserterCategory_)

destring AsserterCategory_1, replace
destring AsserterCategory_2, replace
destring AsserterCategory_3, replace

gen Cat_1 = 1 if AsserterCategory_1==1 | AsserterCategory_2==1 | AsserterCategory_3==1
replace Cat_1 = 0 if Cat_1==. & dataset_Stanford==1
label var Cat_1 "Acquired patents"

gen Cat_2 = 1 if AsserterCategory_1==2 | AsserterCategory_2==2 | AsserterCategory_3==2
replace Cat_2 = 0 if Cat_2==. & dataset_Stanford==1
label var Cat_2 "University heritage or ties"

gen Cat_3 = 1 if AsserterCategory_1==3 | AsserterCategory_2==3 | AsserterCategory_3==3
replace Cat_3 = 0 if Cat_3==. & dataset_Stanford==1
label var Cat_3 "Failed startup"

gen Cat_4 = 1 if AsserterCategory_1==4 | AsserterCategory_2==4 | AsserterCategory_3==4
replace Cat_4 = 0 if Cat_4==. & dataset_Stanford==1
label var Cat_4 "Corporate heritage"

gen Cat_5 = 1 if AsserterCategory_1==5 | AsserterCategory_2==5 | AsserterCategory_3==5
replace Cat_5 = 0 if Cat_5==. & dataset_Stanford==1
label var Cat_5 "Individual inventor-started company"

gen Cat_6 = 1 if AsserterCategory_1==6 | AsserterCategory_2==6 | AsserterCategory_3==6
replace Cat_6 = 0 if Cat_6==. & dataset_Stanford==1
label var Cat_6 "University/Government/NGO"

gen Cat_7 = 1 if AsserterCategory_1==7 | AsserterCategory_2==7 | AsserterCategory_3==7
replace Cat_7 = 0 if Cat_7==. & dataset_Stanford==1
label var Cat_7 "Startup, pre-product"

gen Cat_8 = 1 if AsserterCategory_1==8 | AsserterCategory_2==8 | AsserterCategory_3==8
replace Cat_8 = 0 if Cat_8==. & dataset_Stanford==1
label var Cat_8 "Product Company"

gen Cat_9 = 1 if AsserterCategory_1==9 | AsserterCategory_2==9 | AsserterCategory_3==9
replace Cat_9 = 0 if Cat_9==. & dataset_Stanford==1
label var Cat_9 "Individual"

gen Cat_10 = 1 if AsserterCategory_1==10 | AsserterCategory_2==10 | AsserterCategory_3==10
replace Cat_10 = 0 if Cat_10==. & dataset_Stanford==1
label var Cat_10 "Undetermined"

gen Cat_11 = 1 if AsserterCategory_1==11 | AsserterCategory_2==11 | AsserterCategory_3==11
replace Cat_11 = 0 if Cat_11==. & dataset_Stanford==1
label var Cat_11 "Industry Consortium"

gen Cat_12 = 1 if AsserterCategory_1==12 | AsserterCategory_2==12 | AsserterCategory_3==12
replace Cat_12 = 0 if Cat_12==. & dataset_Stanford==1
label var Cat_12 "IP Subsidiary of Product Company"

gen Cat_13 = 1 if AsserterCategory_1==13 | AsserterCategory_2==13 | AsserterCategory_3==13
replace Cat_13 = 0 if Cat_13==. & dataset_Stanford==1
label var Cat_13 "Corporate-Inventor-Started Company"


// Information on the asserter category for appeals with decisions (cases filed 2011-2016)
tab1 Cat_1 Cat_2 Cat_3 Cat_4 Cat_5 Cat_6 Cat_7 Cat_8 Cat_9 Cat_10 Cat_11 Cat_12 Cat_13 

/////////////////////
gen Multi_categories = 1 if (Cat_1 + Cat_2 + Cat_3 + Cat_4 + Cat_5 + Cat_6 + Cat_7 + Cat_8 + Cat_9 + Cat_10 + Cat_11 + Cat_12 + Cat_13) > 1
replace Multi_categories = 0 if Multi_categories !=1

tab Multi_categories if Case_Filed_Year > 2010 & Case_Filed_Year < 2017
// This shows how many civil actions for appeals with decisions had multiple categories (cases filed 2011-2016). 


****************************************************************
// Part III.C. Frequency of party filing appeal by asserter type
****************************************************************

// As the primary analysis is limited to only first appeals in a civil action, cross appeals do not matter here because we are looking at only the *first* appeal filed for a civil action, which necessarily will be the appellant. Decisions where the appellant was coded as "other" or "patent applicant" are not included in this analysis.

tab Appellant_Type_Cross, missing 
// This provides the number of cases with a cross-appeal

tab Appellant_Type_Primary, missing 
// This provides information on who the appellant was

tab Appellant_Type_Primary if (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")

// Focusing only on categories with at least 20 cases with an appellate decision

tab Appellant_Type_Primary Cat_1 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") 

tab Appellant_Type_Primary Cat_4 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") 

tab Appellant_Type_Primary Cat_5 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") 

tab Appellant_Type_Primary Cat_6 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") 

tab Appellant_Type_Primary Cat_8 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") 

tab Appellant_Type_Primary Cat_9 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") 

tab Appellant_Type_Primary Cat_12 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")


tab AsserterCategory Appellant_Type_Primary if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing
// The data used in Figure 4 (pie chart)


**********************************************************************************
// Analysis of appeals potentially involving preliminary injunctions
**********************************************************************************

merge m:1 uniqueID using "2022-06-30 keyword preliminary injunction.dta" // This merges the dataset with a set of uniqueIDs that are associated with documents that contain the term "preliminary injunction"

drop if _merge==2

drop _merge

tab keyword_preliminary_injunction, missing // Note that these are only appeals with decisions. 

tab keyword_preliminary_injunction Cat_1 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing

tab keyword_preliminary_injunction Cat_4 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing 

tab keyword_preliminary_injunction Cat_5 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing 

tab keyword_preliminary_injunction Cat_6 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing 

tab keyword_preliminary_injunction Cat_8 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing 

tab keyword_preliminary_injunction Cat_9 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing 

tab keyword_preliminary_injunction Cat_12 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing



**********************************************************************************
// Part III.D. Win rates by asserter type
**********************************************************************************

// Due to the method for calculating win rates, cross-appeals add complexity because it is unclear which party "won" the cross-appeal. Consequently, we did not include decisions involving cross-appeals in calculating the win rates in our primary analysis. We report data on appeals with cross-appeals separately. 

// Keep in mind that the record unit remains an appeal, not an appellate decision.

tab Appellant_Type_Primary DispGeneral if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""
//This table shows the outcomes of appeals based on which party filed the appeal. 

tab DispGeneral if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross!=""
// This table shows the outcomes of appeals with a cross-appeal


// Focusing only on categories with at least 20 cases with an appellate decision and excluding cross-appeals

tab Appellant_Type_Primary DispGeneral if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_1 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_4 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_5 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_6 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_8 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_9 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_12 & Appellant_Type_Cross==""

// Limited to only precedential decisions

tab Appellant_Type_Primary DispGeneral if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_1 & Appellant_Type_Cross=="" & PrecedentialStatus=="Precedential"

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_4 & Appellant_Type_Cross=="" & PrecedentialStatus=="Precedential"

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_5 & Appellant_Type_Cross=="" & PrecedentialStatus=="Precedential"

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_6 & Appellant_Type_Cross=="" & PrecedentialStatus=="Precedential"

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_8 & Appellant_Type_Cross=="" & PrecedentialStatus=="Precedential"

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_9 & Appellant_Type_Cross=="" & PrecedentialStatus=="Precedential"

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_12 & Appellant_Type_Cross=="" & PrecedentialStatus=="Precedential"



**********************************************************************************
// Part III.E. Frequency of appellate decisions by document type
**********************************************************************************

tab docType DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")

tab docType DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & Appellant_Type_Primary=="Accused infringer"

tab docType DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & Appellant_Type_Primary=="Patent asserter" 

tab docType DispGeneral if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Patent asserter") & Cat_1 

tab docType DispGeneral if Case_Filed_Year > 2010 & Case_Filed_Year < 2017  & (Appellant_Type_Primary=="Accused infringer") & Cat_1 

tab docType DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Patent asserter") & Cat_5 

tab docType DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer") & Cat_8 

tab docType DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Patent asserter") & Cat_8 

tab docType DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Patent asserter") & Cat_9 


**********************************************************************************
// Repeating selected analyses with All Appeals dataset
**********************************************************************************

// We repeat the following analyses: (1) appellant type; (2) win rates; (3) decision type.

use "Civil Actions to Appellate decisions - all appeals (2011-2016).dta", clear // The record unit is an appeal docket, not an appellate decision. Also note that this is limited to cases filed 2011-2016


// 1. Appellant Type (all appeals)

duplicates tag AsserterCategory, gen(AsserterCategory_n)
tab AsserterCategory if AsserterCategory_n > 20

split AsserterCategory, parse(;) gen(AsserterCategory_) // The split results in a maximum of 3 categories per record.

destring AsserterCategory_1, replace
destring AsserterCategory_2, replace
destring AsserterCategory_3, replace

gen Cat_1 = 1 if AsserterCategory_1==1 | AsserterCategory_2==1 | AsserterCategory_3==1
replace Cat_1 = 0 if Cat_1==. & dataset_Stanford==1
label var Cat_1 "Acquired patents"

gen Cat_2 = 1 if AsserterCategory_1==2 | AsserterCategory_2==2 | AsserterCategory_3==2 
replace Cat_2 = 0 if Cat_2==. & dataset_Stanford==1
label var Cat_2 "University heritage or ties"

gen Cat_3 = 1 if AsserterCategory_1==3 | AsserterCategory_2==3 | AsserterCategory_3==3
replace Cat_3 = 0 if Cat_3==. & dataset_Stanford==1
label var Cat_3 "Failed startup"

gen Cat_4 = 1 if AsserterCategory_1==4 | AsserterCategory_2==4 | AsserterCategory_3==4
replace Cat_4 = 0 if Cat_4==. & dataset_Stanford==1
label var Cat_4 "Corporate heritage"

gen Cat_5 = 1 if AsserterCategory_1==5 | AsserterCategory_2==5 | AsserterCategory_3==5
replace Cat_5 = 0 if Cat_5==. & dataset_Stanford==1
label var Cat_5 "Individual inventor-started company"

gen Cat_6 = 1 if AsserterCategory_1==6 | AsserterCategory_2==6 | AsserterCategory_3==6
replace Cat_6 = 0 if Cat_6==. & dataset_Stanford==1
label var Cat_6 "University/Government/NGO"

gen Cat_7 = 1 if AsserterCategory_1==7 | AsserterCategory_2==7 | AsserterCategory_3==7
replace Cat_7 = 0 if Cat_7==. & dataset_Stanford==1
label var Cat_7 "Startup, pre-product"

gen Cat_8 = 1 if AsserterCategory_1==8 | AsserterCategory_2==8 | AsserterCategory_3==8
replace Cat_8 = 0 if Cat_8==. & dataset_Stanford==1
label var Cat_8 "Product Company"

gen Cat_9 = 1 if AsserterCategory_1==9 | AsserterCategory_2==9 | AsserterCategory_3==9 
replace Cat_9 = 0 if Cat_9==. & dataset_Stanford==1
label var Cat_9 "Individual"

gen Cat_10 = 1 if AsserterCategory_1==10 | AsserterCategory_2==10 | AsserterCategory_3==10
replace Cat_10 = 0 if Cat_10==. & dataset_Stanford==1
label var Cat_10 "Undetermined"

gen Cat_11 = 1 if AsserterCategory_1==11 | AsserterCategory_2==11 | AsserterCategory_3==11
replace Cat_11 = 0 if Cat_11==. & dataset_Stanford==1
label var Cat_11 "Industry Consortium"

gen Cat_12 = 1 if AsserterCategory_1==12 | AsserterCategory_2==12 | AsserterCategory_3==12
replace Cat_12 = 0 if Cat_12==. & dataset_Stanford==1
label var Cat_12 "IP Subsidiary of Product Company"

gen Cat_13 = 1 if AsserterCategory_1==13 | AsserterCategory_2==13 | AsserterCategory_3==133
replace Cat_13 = 0 if Cat_13==. & dataset_Stanford==1
label var Cat_13 "Corporate-Inventor-Started Company"

tab1 Cat_1 Cat_2 Cat_3 Cat_4 Cat_5 Cat_6 Cat_7 Cat_8 Cat_9 Cat_10 Cat_11 Cat_12 Cat_13 


///////////////////////
 
gen Multi_categories = 1 if (Cat_1 + Cat_2 + Cat_3 + Cat_4 + Cat_5 + Cat_6 + Cat_7 + Cat_8 + Cat_9 + Cat_10 + Cat_11 + Cat_12 + Cat_13) > 1
replace Multi_categories = 0 if Multi_categories !=1
tab Multi_categories
// This shows how many civil actions in the all appeals dataset had multiple categories of asserters. 





// 2. Frequency of party filing appeal (all appeals)


tab Appellant_Type_Cross if Case_Filed_Year > 2010 & Case_Filed_Year < 2017, missing // This provides the number of cases with a cross-appeal

tab Appellant_Type_Primary if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")

tab Appellant_Type_Primary if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""

// Focusing only on categories with at least 20 cases with an appellate decision and excluding cases with cross-appeal (because this is not coded separately for each appeal docket)

tab Appellant_Type_Primary Cat_1 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""

tab Appellant_Type_Primary Cat_4 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""

tab Appellant_Type_Primary Cat_5 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""

tab Appellant_Type_Primary Cat_6 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""

tab Appellant_Type_Primary Cat_8 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""

tab Appellant_Type_Primary Cat_9 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""

tab Appellant_Type_Primary Cat_12 if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""


// Analyzing Cross-appeals

// Note that cross-appeals are naturally more frequent in this set because it contains not just the first appeal for a civil action, but subsequent appeals for that civil action. Thus, it will include both the initial appeal (that is matched with a cross-appeal) and the subsequent appeal (that is also coded as a cross appeal)

tab Appellant_Type_Primary Appellant_Type_Cross if Cat_1==1 & Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing

tab Appellant_Type_Primary Appellant_Type_Cross if Cat_8==1 & Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter"), missing

gen Cross_Appeal=1 if Appellant_Type_Cross!=""
replace Cross_Appeal=0 if Cross_Appeal!=1


tab Cross_Appeal if Cat_1==1 & Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")

tab Cross_Appeal  if Cat_4==1 & Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")

tab Cross_Appeal  if Cat_5 ==1 & Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")

tab Cross_Appeal  if Cat_6 ==1 & Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")

tab Cross_Appeal  if Cat_8 ==1 & Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")

tab Cross_Appeal  if Cat_9 ==1 & Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")

tab Cross_Appeal if Cat_12 ==1 & Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter")



// 3. Win rates of asserters (all appeals)

tab Appellant_Type_Primary DispGeneral if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Appellant_Type_Cross==""


// Focusing only on categories with at least 20 cases with an appellate decision. As above, this analysis excludes cases with cross-appeals. 

tab Appellant_Type_Primary DispGeneral if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_1 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_4 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_5 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_6 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_8 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_9 & Appellant_Type_Cross==""

tab Appellant_Type_Primary DispGeneral  if Case_Filed_Year > 2010 & Case_Filed_Year < 2017 & (Appellant_Type_Primary=="Accused infringer" | Appellant_Type_Primary=="Patent asserter") & Cat_12 & Appellant_Type_Cross==""



************************
/* Intercoder agreement analysis of AppellantType field */
************************

ssc install kappaetc

use "appeals 2022-04-06.dta", clear
merge 1:1 uniqueID using  "Second coder for kappa.dta"

encode Appellant_Type_Primary, gen(Appellant_Type_Primary_n)
tab Appellant_Type_Primary Appellant_Type_Primary_n

encode kappa_Appellant_Type_Primary, gen(kappa_Appellant_Type_Primary_n)
tab kappa_Appellant_Type_Primary_n kappa_Appellant_Type_Primary

tab Appellant_Type_Primary_n kappa_Appellant_Type_Primary_n

kappaetc Appellant_Type_Primary_n kappa_Appellant_Type_Primary_n if _merge==3
kappaetc Appellant_Type_Primary_n kappa_Appellant_Type_Primary_n if _merge==3, benchmark(probabilistic) showscale

// Cohen's kappa is interpreted using Gwet's probabilistic approach using Landis & Koch's benchmarking scale, rather than as a deterministic value. 
